#pragma once
#include "task.h"
#include <chrono>
#include <span>
#include <sys/epoll.h>
#include <unistd.h>

namespace cobt {
class FileHandle {
public:
  explicit FileHandle(int fd = -1);
  FileHandle(FileHandle &&that);
  FileHandle &operator=(FileHandle &&that);
  ~FileHandle();
  int get_fd() const noexcept;
  void release() noexcept;
  Task<int> read(std::span<char> buf, std::chrono::milliseconds timeout);
  Task<int> write(std::span<char> buf, std::chrono::milliseconds timeout);

protected:
  int m_fd;
};
} // namespace cobt